<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login - ChatGPT</title>
    <style>
        /* 样式代码与之前保持一致 */
        /* 通用样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: Arial, sans-serif;
            background-color: #f3f4f6;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            color: #333;
        }

        .container {
            background-color: #fff;
            padding: 2rem;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
            text-align: center;
        }

        h1 {
            font-size: 1.8rem;
            margin-bottom: 1.5rem;
            color: #222;
        }

        .form-group {
            margin-bottom: 1.5rem;
            text-align: left;
        }

        label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: bold;
            color: #555;
        }

        input[type="text"],
        input[type="password"],
        select {
            width: 100%;
            padding: 0.8rem;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 1rem;
            color: #333;
        }

        input:focus,
        select:focus {
            outline: none;
            border-color: #4f46e5;
            box-shadow: 0 0 4px rgba(79, 70, 229, 0.5);
        }

        button {
            background-color: #4f46e5;
            color: #fff;
            border: none;
            padding: 0.8rem 1.2rem;
            font-size: 1rem;
            font-weight: bold;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s ease;
            width: 100%;
        }

        button:hover {
            background-color: #4338ca;
        }

        .role-group {
            margin-bottom: 1.5rem;
        }

        .role-group label {
            font-size: 0.9rem;
            font-weight: normal;
        }

        .footer {
            margin-top: 1rem;
            font-size: 0.9rem;
            color: #888;
        }

        .footer a {
            color: #4f46e5;
            text-decoration: none;
        }

        .footer a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Welcome to ChatGPT</h1>
        <form id="loginForm">
            <!-- 用户名输入 -->
            <div class="form-group">
                <label for="username">Username</label>
                <input type="text" id="username" name="username" placeholder="Enter your username" required>
            </div>
            
            <!-- 密码输入 -->
            <div class="form-group">
                <label for="password">Password</label>
                <input type="password" id="password" name="password" placeholder="Enter your password" required>
            </div>
            
            <!-- 角色选择 -->
            <div class="role-group">
                <label for="role">Role</label>
                <select id="role" name="role" required>
                    <option value="user">User</option>
                    <option value="admin">Admin</option>
                </select>
            </div>
            
            <!-- 提交按钮 -->
            <button type="submit">Login</button>
        </form>
        
        <!-- 页脚 -->
        <div class="footer">
            <p>Need help? <a href="/help">Contact Support</a></p>
        </div>
    </div>

    <script>
        // 登录表单提交处理
        document.getElementById("loginForm").addEventListener("submit", function(event) {
            event.preventDefault(); // 阻止默认提交行为
            const role = document.getElementById("role").value;

            // 根据角色跳转到不同的页面
            if (role === "user") {
                window.location.href = "../chat"; // 用户界面
            } else if (role === "admin") {
                window.location.href = "../admin"; // 管理员界面
            }
        });
    </script>
</body>
</html>
